package com.ruoyi.web.controller.applet;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.BdmBalanceChange;
import com.ruoyi.system.domain.dto.BdmBalanceChangeDto;
import com.ruoyi.system.domain.vo.applet.BdmBalanceChangeAmountVo;
import com.ruoyi.system.enums.BdmBalanceChangeEnum;
import com.ruoyi.system.service.IBdmBalanceChangeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 用户 余额 积分 佣金 变动Controller
 * 
 * @author ruoyi
 * @date 2024-12-19
 */
@RestController
@Validated
@RequestMapping("/applet/change")
public class AppletBalanceChangeController extends BaseController
{
    @Autowired
    private IBdmBalanceChangeService bdmBalanceChangeService;


    /**
     * 分页查询当前用户积分明细
     * @return {@link BdmBalanceChange}
     */
    @GetMapping("/listPage")
    public TableDataInfo list( )
    {
        startPage();
        BdmBalanceChangeDto bdmBalanceChangeDto = new BdmBalanceChangeDto();
        bdmBalanceChangeDto.setUserId(getUserId());
        bdmBalanceChangeDto.setVariationType(Long.parseLong(BdmBalanceChangeEnum.INTEGRAL.getType()));
        List<BdmBalanceChange> list = bdmBalanceChangeService.listPage(bdmBalanceChangeDto);
        return getDataTable(list);
    }


    /**
     * 分页查询当前用户余额支出明细
     * @return {@link BdmBalanceChange}
     */
    @GetMapping("/expenditurePage")
    public TableDataInfo expenditurePage( )
    {
        List<BdmBalanceChange> list = bdmBalanceChangeService.expenditurePage(2L);
        return getDataTable(list);
    }

    /**
     * 查询当前用户余额支出明细
     * @param addOrSubtract
     * @return
     */
    @GetMapping("/getExpenditurePage")
    public TableDataInfo getExpenditurePage(Long addOrSubtract) {
        startPage();
        List<BdmBalanceChangeAmountVo> list = bdmBalanceChangeService.getExpenditurePage(addOrSubtract);
        return getDataTable(list);
    }
}
